// pages/goods_detail/goods_detail.js
Page({
  data: {
    goodDetail: {},
    pics: []
  },
  onLoad(query) {
    this.getGoodDetail(query.goods_id)
  },
  async getGoodDetail(goods_id) {
    const res = await wx.http.get('/api/public/v1/goods/detail', {goods_id})
    const goodDetail = res.data.message
    const pics = res.data.message.pics.map(obj => obj.pics_big_url)
    this.setData({goodDetail, pics})
  },
  addCart() {
    wx.showToast({
      title: '已加入购物车'
    })
  },
  goHome() {
    wx.switchTab({
      url: '/pages/index/index'
    })
  },
  goCart() {
    wx.switchTab({
      url: '/pages/cart/cart'
    })
  }
})